package usejava.threadpool;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ViewThreadPoolLock {

    public ViewThreadPoolLock() {

    }

    public static void main(String[] args) {

        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 5, 120, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5));

        // 分析源码执行中加锁过程, 内部调用addWorker(Runnable firstTask, boolean core)
        // 同时注意 内部类 Worker
        // private final class Worker
        //        extends AbstractQueuedSynchronizer
        //        implements Runnable
        threadPoolExecutor.execute(() -> System.out.println("run success"));

        threadPoolExecutor.shutdown();
    }
}
